package com.rigsofrods.truckeditor.rig.parser;

import java.text.ParseException;
import java.util.InputMismatchException;
import java.util.Locale;
import java.util.Scanner;

import com.rigsofrods.truckeditor.rig.NodeDefaults;
import com.rigsofrods.truckeditor.rig.TruckModel;
import com.rigsofrods.truckeditor.rig.TruckTreeNode;


public class NodeDefaultsParser implements IRigParser {

	@Override
	public boolean parseLine(String line, TruckModel truck) throws ParseException {
		double loadweight;
		double traction;
		double buoyancy;
		double surface;
		String options = "";
		
		Scanner scn = new Scanner(line);
		scn.useLocale(Locale.US);
		scn.useDelimiter("(\\s+|,\\s*)");
		scn.skip("set_node_defaults");
		try{
			loadweight = scn.nextDouble();
			traction = scn.nextDouble();
			buoyancy = scn.nextDouble();
			surface = scn.nextDouble();
			if(scn.hasNext()) options = scn.next();
		}catch (InputMismatchException e) {
			return false;
		}finally{
			scn.close();
		}
		//TODO: check values
		//return new NodeDefaults(loadweight, traction, buoyancy, surface, options);
		return true;
	}

	@Override
	public String getErrorMessage() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public boolean requestComments() {
		return false;
	}
}
